<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>应用JavaScript的onmouseover等事件和className属性设计横向导航菜单</title>
<link href="css/css.css" rel="stylesheet" type="text/css"/>
<link href="css/main.css" rel="stylesheet" type="text/css" />
<style>
#nav li:hover ul {
 left: auto;
}
#nav li.sfhover ul {
 left: auto;
}
</style>
<script type="text/javascript">
function menuFix() {
 var sfEls = document.getElementById("nav").getElementsByTagName("li");
 for (var i=0; i<sfEls.length; i++) {
  sfEls[i].onmouseover=function() {
  this.className+=(this.className.length>0? " ": "") + "sfhover";
  }
  sfEls[i].onmouseout=function() {
	this.className=this.className.replace(new RegExp("( ?|^)sfhover\\b"),"");
  }
 }
}
window.onload=menuFix;
</script>
</head>

<body>
<div id="daohang"> 
  <ul id="nav">
    <li><a href="index.html">首页</a></li>
    <li><a href="#">功能手机</a>
      <ul>
        <li><a href="" target="_blank">音乐手机</a></li>
        <li><a href="" target="_blank">商务手机</a></li>
      </ul>
    </li>
    <li><a href="" target="_blank">手机配件</a>
      <ul>
        <li><a href="" target="_blank">耳机</a></li>
        <li><a href="" target="_blank">电池</a></li>
      </ul>
    </li>
    <li><a href="" target="_blank">服务政策</a>
    </li>
    <li><a href="" target="_blank">关于我们</a>
    </li>
    <li><a href="" target="_blank">联系我们</a></li>
  </ul>
</div>
</body>
</html>
